﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Core;
using System.Data;
using System.Data.SqlClient;
using BestLifePOS_Core.Exceptions.DataBase;

namespace BestLifePOS_Core.Data.Commands
{
    class BestLifeUpdatePurchaseOrderDataAction : BestLifeDataAction<int>
    {
        private string Gvxml;
        private string GvStatus;
        public BestLifeUpdatePurchaseOrderDataAction(string PPOList, string PStatus)
        {

            Gvxml = PPOList;
            GvStatus = PStatus;
        }

        public override int Body(SqlConnection PConn)
        {
            try
            {

                SqlCommand LvCommand = new SqlCommand();
                LvCommand.Connection = PConn;
                LvCommand.CommandType = CommandType.StoredProcedure;
                LvCommand.CommandText = "dbo.UpdatePurchaseOrder";
                LvCommand.Parameters.AddWithValue("@POdetails", Gvxml);//when passing parameters to the SP                  
                LvCommand.Parameters.AddWithValue("@status", GvStatus.ToString());

                int LvCount = LvCommand.ExecuteNonQuery();
                return LvCount;
            }



            catch (BestlifeDatabaseException e)
            {
                throw new BestlifeDatabaseException(e);
            }
        }
    }

}


